package com.xayy.health.mgt.controller;

import java.util.HashMap;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import com.xayy.health.mgt.model.AssessParma;
import com.xayy.health.mgt.model.dto.AssessParmaPageDto;
import com.xayy.health.mgt.model.vo.AssessParmaVo;
import com.xayy.health.mgt.service.AssessParmaService;

import cn.kawins.base.result.ResultBody;
import cn.kawins.mybatis.base.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;

/**
 * 健康评估模型管理
 *
 * @author Nie
 * @version v1.0
 * @Date 2022-05-31 14:10
 */
@RestController
@RequestMapping("/assessmentModel")
@Api(tags = "健康评估模型管理")
public class AssessParmaController extends BaseController<AssessParma> {

    @Autowired
    private AssessParmaService assessParmaService;

    @PostMapping("/check/assessParma")
    @ApiOperation(value = "新增修改前统一校验默认模型")
    public ResultBody checkAssessParma(@RequestBody @Validated AssessParma assessParma) {
        return assessParmaService.checkAssessParma(assessParma).body();
    }

    @PostMapping("/insert/assessParma")
    @ApiOperation(value = "新增提示替换默认模型所掉接口")
    public ResultBody insertAssessParma(@RequestBody @Validated AssessParma assessParma) {
        assessParma.setId(null);
        return assessParmaService.insertAssessParma(assessParma, false).body();
    }

    @PostMapping("/update/assessParma")
    @ApiOperation(value = "修改提示替换默认模型所掉接口")
    public ResultBody updateAssessParma(@RequestBody AssessParma assessParma) {
        return assessParmaService.updateAssessParma(assessParma, false).body();
    }

    /**
     * 删除配置管理健康评估模型
     * 
     * @param id
     *            评估id
     * @return ResultBody
     */
    @GetMapping("/delete/assessParma/{id}")
    @ApiOperation(value = "删除配置管理健康评估模型")
    public ResultBody deleteAssessParma(@PathVariable("id") Long id) {
        return assessParmaService.deleteAssessParma(id).body();
    }

    @PostMapping("/select/assessParma")
    @ApiOperation(value = "查询配置管理健康评估模型")
    @ApiResponses({@ApiResponse(code = 200, message = "", response = AssessParma.class)})
    public ResultBody selectAssessParma(@RequestBody AssessParmaPageDto assessParmaPageDto) {
        HashMap<String, Object> map = new HashMap<>(1);
        map.put("satId", assessParmaPageDto.getSatId());
        map.put("sysId", assessParmaPageDto.getSysId());
        map.put("comId", assessParmaPageDto.getComId());
        return dataPage("selectAssessParma", map);
    }

    /**
     * 查询配置管理健康评估模型详情信息
     * 
     * @param id
     *            评估id
     * @return ResultBody
     */
    @GetMapping("/select/assessModel/{id}")
    @ApiOperation(value = "查询配置管理健康评估模型详情信息")
    @ApiResponses({@ApiResponse(code = 200, message = "", response = AssessParma.class)})
    public ResultBody selectAssessModel(@PathVariable("id") Long id) {
        return assessParmaService.selectAssessModel(id).body();
    }

    @GetMapping("/selectAssessParmaBySat/{satId}")
    @ApiOperation(value = "查询卫星下以及配置的评估模型列表，新建下拉框列表")
    @ApiResponses({@ApiResponse(code = 200, message = "", response = AssessParmaVo.class)})
    public ResultBody selectAssessParmaBySat(@PathVariable("satId") Long satId) {
        return assessParmaService.selectAssessParmaBySat(satId).body();
    }

}
